package ZY11_09;

import java.util.*;

public class XingNeng {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入拼接长度：");
        while (sc.hasNext()) {
            int num = sc.nextInt();
            StringBuilder alist = new StringBuilder();
            StringBuffer llist = new StringBuffer();
            long startTime = System.currentTimeMillis();    //获取开始时间

            for (int i = 0; i < num; i++) {
                alist.append(i);
            }   //测试的代码段

            long endTime = System.currentTimeMillis();    //获取结束时间

            System.out.println("StringBuilder程序运行时间：" + (endTime - startTime) + "ms");    //输出程序运行时间

            long startTime1 = System.currentTimeMillis();    //获取开始时间

            for (int i = 0; i < num; i++) {
                llist.append(i);
            }   //测试的代码段

            long endTime1 = System.currentTimeMillis();    //获取结束时间

            System.out.println("StringBuffer程序运行时间：" + (endTime1 - startTime1) + "ms");    //输出程序运行时间
        }
    }
}
